#ifndef QBCIGLOBAL_H
#define QBCIGLOBAL_H
#include <QHash>
#include <QLogger>
#include <QSemaphore>
#include <QSharedPointer>
#include <QVariant>

#include "qbciconfig.h"
#include "qbcisignal.h"

#define BCI_MODULE Q_OBJECT

namespace bci {
/**
 * @brief QBciContext for share context
 * between QBci and sub modules
 *
 * @note QBciContext's members must be
 * thread-safe
 */
struct QBciContext {
  QBciContext(const int &semCount, const QString &lgName)
      : sem(new QSemaphore(semCount)), logger(new QLogger(lgName)) {}
  QSharedPointer<QSemaphore> sem;
  QSharedPointer<QLogger> logger;
  QThread *mainThread = nullptr;
};

typedef QHash<QString, QVariant> QBciRes;

class QBciDebug {
public:
  static QString threadId2QStr(const Qt::HANDLE &id) {
    return QString::number((unsigned long long)id, 16);
  }
};
} // namespace bci
#endif